//
//  UserExtensionTableViewCell.m
//  XinKaiFa55like
//
//  Created by junseek on 2017/3/24.
//  Copyright © 2017年 55like lj. All rights reserved.
//

#import "UserExtensionTableViewCell.h"

@interface UserExtensionTableViewCell (){    //
    
    NSIndexPath *tempIndexPath;
    NSDictionary *tempDic;
    
    NSInteger numTemp;
    UIImageView *imageMore;
}

@end
@implementation UserExtensionTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        float fw=25;
        float fjg=10;
        numTemp=kScreenWidth/(fw+fjg);
        
        for (int i=0; i<numTemp; i++) {
            UIImageView *imageLogo=[RHMethods imageviewWithFrame:CGRectMake(fjg+(fw+fjg)*i, 5, fw, fw) defaultimage:@"newPic"];
            [self addSubview:imageLogo];
            [[Utility Share] viewLayerRound:imageLogo borderWidth:0.5 borderColor:[UIColor clearColor]];
            imageLogo.tag=10+i;
            if (i==numTemp-1) {
                imageMore=[RHMethods imageviewWithFrame:imageLogo.frame defaultimage:@"moreicon" contentMode:UIViewContentModeCenter];
                [self addSubview:imageMore];
            }
        }
        
        [self addSubview:[RHMethods lineViewWithFrame:CGRectMake(0, 34.5, kScreenWidth, 0.5)]];
        [self setSelectionStyle:UITableViewCellSelectionStyleGray];
    }
    return self;
}

//内容更新
-(void)setValueForDictionary:(NSDictionary *)dic indexPath:(NSIndexPath *)indexPath type:(NSString *)strType{
    tempIndexPath=indexPath;
    tempDic=dic;
    
    NSArray *arrayImages=[dic objectForJSONKey:@"people"];
    for (int i=0; i<numTemp; i++) {
        UIImageView *imageLogo=[self viewWithTag:i+10];
        if ([arrayImages count]>i) {
            imageLogo.hidden=NO;
            if (i==numTemp-1 && indexPath.section>numTemp) {
                imageMore.hidden=NO;
                imageLogo.hidden=YES;
            }else{
                imageMore.hidden=YES;
                [imageLogo imageWithURL:[arrayImages[i] valueForJSONStrKey:@"icon"] useProgress:NO useActivity:NO];
            }
        }else{
            imageLogo.hidden=YES;
        }
    }    
    
    //h:35
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
